from piercing.pierc_common import ToolStuckParams
import math


# 卡点计算
# 钻柱卡点深度计算
def get_tool_stuck_point(params: ToolStuckParams) -> float:
    # 平均上提位移 L
    L: float = (params.first_pull_up_displacement + params.second_pull_up_displacement + params.third_pull_up_displacement) / 3
    # 平均悬重增量 d
    d: float = ((params.first_pull_up_tension - params.initial_tension) + (params.second_pull_up_tension - params.initial_tension) + (params.third_pull_up_tension - params.initial_tension)) / 3
    # 钻柱卡点深度 z
    z: float = L * params.extension_coefficient / d
    return z

if __name__ == '__main__':
    params = ToolStuckParams()
    params.initial_tension = 600
    params.extension_coefficient = 7150
    params.first_pull_up_displacement = 25
    params.first_pull_up_tension = 720
    params.second_pull_up_displacement = 44
    params.second_pull_up_tension = 800
    params.third_pull_up_displacement = 70
    params.third_pull_up_tension = 900
    z = get_tool_stuck_point(params)
    print(z)

